package com.jr.pojo;

import java.sql.Timestamp;
import java.util.Date;

public class Salaries {

    private Integer id; //薪酬记录ID
    private Integer employeeId; //员工ID
    private Date effectiveDate; //生效日期

    private Double baseSalary; //基本工资
    private Double bonus; //奖金
    private Double benefits; //福利

    private Double insurance; //保险
    private Double tax; //税费
    private String description; //描述

    private Timestamp createdAt; //创建时间
    private Timestamp updatedAt; //更新时间

    public Salaries() {
    }

    public Salaries(Integer id, Integer employeeId, Date effectiveDate,
                    Double baseSalary, Double bonus, Double benefits,
                    Double insurance, Double tax, String description,
                    Timestamp createdAt, Timestamp updatedAt) {
        this.id = id;
        this.employeeId = employeeId;
        this.effectiveDate = effectiveDate;
        this.baseSalary = baseSalary;
        this.bonus = bonus;
        this.benefits = benefits;
        this.insurance = insurance;
        this.tax = tax;
        this.description = description;
        this.createdAt = createdAt;
        this.updatedAt = updatedAt;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Integer getEmployeeId() {
        return employeeId;
    }

    public void setEmployeeId(Integer employeeId) {
        this.employeeId = employeeId;
    }

    public Date getEffectiveDate() {
        return effectiveDate;
    }

    public void setEffectiveDate(Date effectiveDate) {
        this.effectiveDate = effectiveDate;
    }

    public Double getBaseSalary() {
        return baseSalary;
    }

    public void setBaseSalary(Double baseSalary) {
        this.baseSalary = baseSalary;
    }

    public Double getBonus() {
        return bonus;
    }

    public void setBonus(Double bonus) {
        this.bonus = bonus;
    }

    public Double getBenefits() {
        return benefits;
    }

    public void setBenefits(Double benefits) {
        this.benefits = benefits;
    }

    public Double getInsurance() {
        return insurance;
    }

    public void setInsurance(Double insurance) {
        this.insurance = insurance;
    }

    public Double getTax() {
        //全月应纳所得税 = 税前收入(工资+奖金) - 5000 - 专项扣除 - 专项附加扣除 - 依法确定的其他扣除
        //税费 = 全月应纳所得税*税率-速算口述费
        /*超过5000的部分：
        * 不超过 36000元       税率3% 速算扣除数=0
        * 超过 36000~14400元  税费10% 速算扣除数 = 2520
        * 超过 14400~300000元  税费20% 速算扣除数 = 16920
        */
        Double incomeTax = this.baseSalary+this.bonus-5000-this.insurance;
        if(incomeTax<=0){
            tax = 0.0;
        } else if (incomeTax>0&&incomeTax<=36000) {
            tax = incomeTax*0.03;
        }else if (incomeTax>36000&&incomeTax<=144000) {
            tax = incomeTax*0.1-2520;
        }else if (incomeTax>144000&&incomeTax<=300000) {
            tax = incomeTax*0.2-16920;
        }else if (incomeTax>300000&&incomeTax<=420000) {
            tax = incomeTax*0.25-31920;
        }else if (incomeTax>420000&&incomeTax<=660000) {
            tax = incomeTax*0.30-52920;
        }else if (incomeTax>660000&&incomeTax<=960000) {
            tax = incomeTax*0.35-85920;
        }else if (incomeTax>960000) {
            tax = incomeTax*0.45-181920;
        }
        return tax;
    }

    public void setTax(Double tax) {
        this.tax = tax;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Timestamp getCreatedAt() {
        return createdAt;
    }

    public void setCreatedAt(Timestamp createdAt) {
        this.createdAt = createdAt;
    }

    public Timestamp getUpdatedAt() {
        return updatedAt;
    }

    public void setUpdatedAt(Timestamp updatedAt) {
        this.updatedAt = updatedAt;
    }
}
